package com.threeti.mecool.core.util;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;

public abstract class SecurityUtil {
  
  public static void putUserInSession(UserDetails userDetails) {
    SecurityContext context = SecurityContextHolder.getContext();
    UsernamePasswordAuthenticationToken authentication = 
        new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
    context.setAuthentication(authentication);
  }
}
